

package com.hazelcast.client.impl.protocol.task.schema;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.codec.ClientSendAllSchemasCodec;
import com.hazelcast.client.impl.protocol.task.AbstractAsyncMessageTask;
import com.hazelcast.instance.impl.Node;
import com.hazelcast.internal.nio.Connection;
import com.hazelcast.internal.serialization.impl.compact.Schema;
import com.hazelcast.internal.serialization.impl.compact.SchemaService;
import com.hazelcast.internal.serialization.impl.compact.schema.MemberSchemaService;

import java.security.Permission;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public class SendAllSchemasMessageTask extends AbstractAsyncMessageTask<List<Schema>, Void> {

    public SendAllSchemasMessageTask(ClientMessage clientMessage, Node node, Connection connection) {
        super(clientMessage, node, connection);
    }

    @Override
    protected CompletableFuture<Void> processInternal() {
        MemberSchemaService memberSchemaService = getService(getServiceName());
        return memberSchemaService.putAllAsync(parameters);
    }

    @Override
    protected List<Schema> decodeClientMessage(ClientMessage clientMessage) {
        return ClientSendAllSchemasCodec.decodeRequest(clientMessage);
    }

    @Override
    protected ClientMessage encodeResponse(Object response) {
        return ClientSendAllSchemasCodec.encodeResponse();
    }

    @Override
    public String getServiceName() {
        return SchemaService.SERVICE_NAME;
    }

    @Override
    public Permission getRequiredPermission() {
        return null;
    }

    @Override
    public String getDistributedObjectName() {
        return null;
    }

    @Override
    public String getMethodName() {
        return null;
    }

    @Override
    public Object[] getParameters() {
        return null;
    }
}
